<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="../inc/conn.asp"-->
<!--#include file="../inc/md5.asp"-->
<!--#include file="../common/admin.asp"-->
<%
id=request.QueryString("edit")
if id<>"" then
	  set rsm=server.CreateObject("adodb.recordset")
	  sql="select * from packagecost where id="&id&""
	  rsm.open sql,conn,1,3
	  if not rsm.eof then
          title=rsm("title")
	  rsm.close
	  set rsm=nothing
	  end if
end if
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>main</title>
<link href="../css/style.css" rel="stylesheet" type="text/css"/>
</head>

<body>
<div class="main">
  <div class="main-title">类目</div>
  <div class="main-content">
  <%if id<>"" then%>
  <table width="100%" border="0" cellspacing="1" cellpadding="3" class="tab">
  <tr>
    <td colspan="6">
    <form name="form" method="post" action="">
    名称<input name="title" type="text" class="input" id="title" value="<%=title%>" maxlength="50" />
    <input name="id" type="hidden" id="id" value="<%=id%>" />
<input type="submit" name="button" id="button" value="保存" />
    </form>
    </td>
    </tr>
    </table>
  <%else%>
  <table width="100%" border="0" cellspacing="1" cellpadding="3" class="tab">
  <tr>
    <td colspan="6">
    <form name="form" method="post" action="">
    名称<input name="title" type="text" class="input" id="title" value="名称" maxlength="50" />
    <input type="submit" name="button" id="button" value="添加" />
    </form>
    </td>
    </tr>
    </table>
  <table width="100%" border="0" cellspacing="1" cellpadding="3" class="tab">
  <tr>
    <td bgcolor="#FFFFFF"><strong>名称</strong></td>
    <td align="center" bgcolor="#FFFFFF"><strong>操作</strong></td>
    <td align="center" bgcolor="#FFFFFF"><strong>删除</strong></td>
    </tr>
     <%
					  set rsu=server.CreateObject("adodb.recordset")
					  sql="select * from packagecost where fid=0 "
					  rsu.open sql,conn,1,3
					  if not rsu.eof then
					  do while not rsu.eof
					  %>
  <tr>
    <td bgcolor="#FFFFFF"><%=rsu("title")%></td>
    <td align="center" bgcolor="#FFFFFF"><a href="?edit=<%=rsu("id")%>">修改</a></td>
    <td align="center" bgcolor="#FFFFFF"><a href="?del=<%=rsu("id")%>">删除</a></td>
    </tr>
    <%
					  rsu.movenext
					  loop
					  rsu.close
					  set rsu=nothing
					  end if		 
					  %>
  
  </table>
  <%end if%>
</div>
</div>
</body>
</html>
<%
if request.Form("button")="添加" then

	title=request.Form("title")

	set rsu=server.createobject("adodb.recordset")
	sql="select * from packagecost"
	rsu.open sql,conn,1,3
	rsu.addnew
	rsu("title")=title
	rsu.update
	response.write"<script language=JavaScript>{window.alert('添加成功！');window.location.href='type.asp';}</script>"
	rsu.close
	set rsu=nothing
	
elseif request.Form("button")="保存" then

	title=request.Form("title")

	set rsu=server.createobject("adodb.recordset")
	sql="select * from packagecost where id="&id&""
	rsu.open sql,conn,1,3
	rsu("title")=title
	rsu.update
	response.write"<script language=JavaScript>{window.alert('保存成功！');window.location.href='type.asp';}</script>"
	rsu.close
	set rsu=nothing

elseif request.QueryString("del")<>"" then
    conn.execute("delete from packagecost where id="&request.QueryString("del")&"")
	response.Redirect "type.asp"
end if
%>